﻿using System;
using System.Web;
using ejunkey.Models;

[Serializable]
public sealed class SessionSingleton
{
    #region Singleton

    private const string SESSION_SINGLETON_NAME = "Singleton_502E69E5-668B-E011-951F-00155DF26207";

    private SessionSingleton()
    {

    }

    public static SessionSingleton Current
    {
        get
        {
            if (HttpContext.Current.Session[SESSION_SINGLETON_NAME] == null)
            {
                HttpContext.Current.Session[SESSION_SINGLETON_NAME] = new SessionSingleton();
                Product product = new Product();
                product.ProductName = "Name Product";
                product.IsSingleFile = false;
                product.IsRedirection = false;
                product.IsStoreCode = true;
                product.IsGenCode = false;
                product.IsAffectOrtherProducts = false;
                product.IsInventoryControl = true;
                product.IsTaxVAT = false;
                product.IsShipOrBuyerAddress = false;
                product.IsEditQuantity = true;
                product.IsEditPrice = false;
                product.IsVariants = false;
                product.IsVariations = false;
                product.IsSendTransaction = false;
                product.IsReceiveCopy = true;
                product.IsEnableTemplateEmail = true;
                product.EmailSubject = "[%item_name%] Purchase";
                ((SessionSingleton)HttpContext.Current.Session[SESSION_SINGLETON_NAME]).SessionProduct = product;
                ((SessionSingleton)HttpContext.Current.Session[SESSION_SINGLETON_NAME]).SessionIsEdit = false;
            }

            return HttpContext.Current.Session[SESSION_SINGLETON_NAME] as SessionSingleton;
        }
    }

    #endregion

    public Product SessionProduct { get; set; }
    public Boolean SessionIsEdit { get; set; }
}